@@ -7,6 +7,18 @@ |
||
7 | 7 |
|
8 | 8 |
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :class => 'form-horizontal' }) do |f| %> |
9 | 9 |
<%= devise_error_messages! %> |
10 |
+ <% if ENV['ON_HEROKU'] && User.count.zero? %> |
|
11 |
+ <div class="heroku-instruction"> |
|
12 |
+ <% app_name = request.host[/\A.+/] %> |
|
13 |
+ <p>If you are the owner of this application, run the following commands to complete the setup.</p> |
|
14 |
+ <%= content_tag :pre do -%> |
|
15 |
+heroku git:clone <%= app_name %> |
|
16 |
+cd <%= app_name %> |
|
17 |
+bundle |
|
18 |
+bin/setup_heroku |
|
19 |
+ <%- end %> |
|
20 |
+ </div> |
|
21 |
+ <% end %> |
|
10 | 22 |
|
11 | 23 |
<div class="form-group"> |
12 | 24 |
<%= f.label :invitation_code, :class => 'col-md-4 control-label' %> |
@@ -48,6 +48,7 @@ def set_value(key, value, options = {}) |
||
48 | 48 |
if $config[key].nil? || $config[key] == '' || ($config[key] != value && options[:force] != false) |
49 | 49 |
puts "Setting #{key} to #{value}" unless options[:silent] |
50 | 50 |
puts capture("heroku config:set #{key}=#{value}") |
51 |
+ $config[key] = value |
|
51 | 52 |
end |
52 | 53 |
end |
53 | 54 |
|
@@ -94,11 +95,15 @@ unless $config['APP_SECRET_TOKEN'] |
||
94 | 95 |
puts capture("heroku config:set APP_SECRET_TOKEN=`rake secret`") |
95 | 96 |
end |
96 | 97 |
|
98 |
+unless $config['DOMAIN'] |
|
99 |
+ set_value 'DOMAIN', "#{app_name}.herokuapp.com", force: false |
|
100 |
+ first_time = true |
|
101 |
+end |
|
102 |
+ |
|
97 | 103 |
set_value 'BUILDPACK_URL', "https://github.com/ddollar/heroku-buildpack-multi.git" |
98 | 104 |
set_value 'PROCFILE_PATH', "deployment/heroku/Procfile.heroku", force: false |
99 | 105 |
set_value 'ON_HEROKU', "true" |
100 | 106 |
set_value 'FORCE_SSL', "true" |
101 |
-set_value 'DOMAIN', "#{app_name}.herokuapp.com", force: false |
|
102 | 107 |
set_value 'USE_GRAPHVIZ_DOT', 'dot' |
103 | 108 |
|
104 | 109 |
unless $config['INVITATION_CODE'] |
@@ -133,6 +138,19 @@ unless $config['SMTP_DOMAIN'] && $config['SMTP_USER_NAME'] && $config['SMTP_PASS |
||
133 | 138 |
end |
134 | 139 |
end |
135 | 140 |
|
141 |
+if first_time |
|
142 |
+ puts "Restarting..." |
|
143 |
+ puts capture("heroku restart") |
|
144 |
+ |
|
145 |
+ puts "Done!" |
|
146 |
+ puts |
|
147 |
+ puts "Visit https://#{app_name}.herokuapp.com/users/sign_up and use the invitation code shown below:" |
|
148 |
+ puts |
|
149 |
+ puts "\t#{$config['INVITATION_CODE']}" |
|
150 |
+ |
|
151 |
+ exit |
|
152 |
+end |
|
153 |
+ |
|
136 | 154 |
branch = capture("git rev-parse --abbrev-ref HEAD") |
137 | 155 |
if yes?("Should I push your current branch (#{branch}) to heroku?") |
138 | 156 |
puts "This may take a moment..." |
@@ -158,4 +176,4 @@ if yes?("Should I push your current branch (#{branch}) to heroku?") |
||
158 | 176 |
end |
159 | 177 |
|
160 | 178 |
puts |
161 |
-puts "Done!" |
|
179 |
+puts "Done!" |